
<?php

	class UserDAO {
		
		public static function authenticate($username) {
			
			$valid = false;
			
			if ($username === "Olivier" || $username === "Guy" || $username === "Matthew") {
				
				$valid = true;
				UserDAO::connectDB();	
			}
			
			return $valid;
		}
		
		private static function connectDB() {
		
		$con = mysql_connect("localhost","root");
		
		if (!$con)
		{
		  	die('Could not connect: ' . mysql_error());
		}
		
		if (mysql_query("CREATE DATABASE db_players",$con))
		{
		  	echo "Database created";
		}
		else
		{
		  	echo "Error creating database: " . mysql_error();
		}
		
		mysql_close($con);
		}			
	}
	
	